package com.ericsson.rm.dao;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.ericsson.rm.model.SkillDetail;

@Repository
public class SkillDetailDaoImpl implements SkillDetailDao {

	@Autowired
	EntityManagerFactory factory;

	@SuppressWarnings("unchecked")
	public List<SkillDetail> fetchAllSkillDetail() {
		System.out.println("Insert into dao");
		EntityManager entityManager = factory.createEntityManager();
		Query q = entityManager.createNamedQuery("SkillDetail.findAll",
				SkillDetail.class);
		// System.out.println("ooooooooooooooooooooooo"+q.getResultList().size());

		return q.getResultList();
	}
	
	public String fetchSkillIdBySkillDesc(String skillDesc) {
		EntityManager entityManager = factory.createEntityManager();
		Query q = entityManager.createNamedQuery("SkillDetail.findId",
				SkillDetail.class);
		return q.toString();

	}
}
